<template>
  <div class="container">
    <van-popup class="popup" v-model:show="showLeft" close-on-click-overlay position="left"
      :style="{ width: '45%', height: '100%' }">
      <ul>
        <li class="list-items" @click="ClickToIndex"><van-icon class="icon" name="orders-o" />接单大厅<van-icon class="arrow" name="arrow" /></li>
        <li class="list-items" @click="ClickToseta"><van-icon class="icon" name="records-o" />已接订单<van-icon class="arrow" name="arrow" /></li>
        <van-divider />
        <li class="list-items" @click="ClickToMind"><van-icon class="icon" name="user-circle-o" />个人中心<van-icon class="arrow" name="arrow" /></li>
      </ul>
    </van-popup>
    <div class="header">
      <van-icon name="wap-nav" class="dh" @click="togglePopup" color="#fff" size="30"></van-icon>
      <div class="title">设置</div>
    </div>
    <div class="main">
      <div class="user-info" @click="goToMind">
        <div class="user-profile">
          <div class="avatar-container">
            <img :src="avatar" alt="头像" class="avatar">
          </div>
          <div class="user-details">
            <div class="username">{{ name }}</div>
            <div class="user-id">ID: 10001</div>
          </div>
        </div>
      </div>

      <div class="menu-list">
        <div class="menu-item" @click="goToSetOrder">
          <div class="menu-title">已发布订单</div>
          <div class="arrow">></div>
        </div>
        <div class="menu-item" @click="goToSetAccept">
          <div class="menu-title">已接受订单</div>
          <div class="arrow">></div>
        </div>
      </div>
    </div>


  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const name = ref('小哥')
const avatar = ref('/src/assets/avatar.jpg')
// 抽屉
const router = useRouter()
const togglePopup = () => {
  showLeft.value = !showLeft.value
}
const showLeft = ref(false)
const active = ref(0);
// 跳转路由
const ClickToIndex = () => {
  router.push('/Index')
}
const ClickToseta = () => {
  router.push('/set-accept')
}
const ClickToMind = () => {
  router.push('/set')
}
const goToMind = () => {
  router.push('/mind')
}

const goToSetOrder = () => {
  router.push('/set-order')
}

const goToSetAccept = () => {
  router.push('/set-accept')
}
</script>

<style scoped>
@import '../assets/dh.css';

.container {
  background: linear-gradient(180deg, rgba(195, 207, 226, 1) 0%, rgba(245, 247, 250, 1) 100%);
  min-height: 100vh;
}

.header {
  background-color: #4050B5;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  position: relative;
}

.dh {
  position: absolute;
  left: 20px;
}

.title {
  text-align: center;
  color: #fff;
  font-size: 18px;
  margin: 0;
  letter-spacing: 4px;
}

.main {
  margin: 10px 14px;
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: transparent;
  padding: 20px 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  box-shadow: none;
  cursor: pointer;
}

.user-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-grow: 1;
}

.avatar-container {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #4050B5;
  margin-bottom: 10px;
  box-shadow: 0 3px 8px rgba(64, 80, 181, 0.3);
}

.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-details {
  text-align: center;
}

.username {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.user-id {
  font-size: 14px;
  color: #666;
}

.menu-list {
  background-color: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-title {
  font-size: 16px;
  color: #333;
}

.arrow {
  color: #999;
  font-size: 18px;
}
</style>